import 'package:app/common/app_theme.dart';
import 'package:app/common/colors.dart';
import 'package:app/common/tool.dart';
import 'package:app/components/base_scaffold_appbar.dart';
import 'package:app/components/custom_textfield_formatter.dart';
import 'package:app/pages/contract_module/create_contract_module/create_contract_controller.dart';
import 'package:app/utils/search_module.dart';
import 'package:bruno/bruno.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:get/get.dart';

import '../../../components/bottom_enter_page.dart';

class CreateContractView extends GetView{

  CreateContractController controller = Get.put(CreateContractController());

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
      // resizeToAvoidBottomInset: false, // 就是这里
      backgroundColor: AppColor.bgColor,
      appBar: BaseAppBar(
        preferredSize: Size(Get.width, AppTool.appBarHEIGHT),
        child:controller.contractId==0?Text('创建合同'):Text('修改合同'),
      ),
      // AppBar(
      //   title: Text('创建合同'),
      //   backgroundColor: AppColor.themeColor,
      //   leading: IconButton(
      //     onPressed: () {
      //       Get.back();
      //     },
      //     icon: Image.asset(
      //       'images/leftarr.png',
      //       color: Colors.white,
      //       width: 15,
      //       height: 15,
      //     ),
      //   ),
      // ),
      body: GetBuilder<CreateContractController>(builder: (_){
        return GestureDetector(

          behavior: HitTestBehavior.translucent,
          onTap: () {
            /// 页面点击响应
            SearchModule.closeKeyboard(context);
          },
          onPanDown: (_) {
            /// 列表滑动响应
            SearchModule.closeKeyboard(context);
          },
          child: Column(
            children: [
              Expanded(child: ListView(
                children: [
                  BrnInputText(
                    padding: EdgeInsets.only(left: 10,right: 10,top: 10,bottom: 10),
                    textEditingController: controller.nameTF,
                    maxLength: 25,
                    hint: '请输入合同名称',
                  ),
                  SizedBox(height: 1,),
                  GestureDetector(
                      onTap: () async {
                        controller.tapClickStartTime();
                      },
                      child: Container(
                        padding: EdgeInsets.fromLTRB(10, 10, 5, 10),
                        color: Colors.white,
                        child: Row(
                          mainAxisAlignment: MainAxisAlignment.spaceBetween,
                          children: [
                            Text("开始时间",style: appThemeData.textTheme.bodyText1,),
                            // SizedBox(height: 12,),
                            Container(
                                height: 40,
                                child: Row(
                                  mainAxisAlignment:
                                  MainAxisAlignment.spaceAround,
                                  crossAxisAlignment: CrossAxisAlignment.center,
                                  children: [
                                    Text('${controller.startTime}',style: appThemeData.textTheme.subtitle1,),
                                    Icon(
                                      Icons.arrow_forward_ios,
                                      size: 15,
                                      color: AppColor.smallTextColor,
                                    )
                                  ],
                                )),
                          ],
                        ),
                      )),
                  SizedBox(height: 1,),
                  GestureDetector(
                      onTap: () async {
                        controller.tapClickEndTime();
                      },
                      child: Container(
                        padding: EdgeInsets.fromLTRB(10, 10, 5, 10),
                        color: Colors.white,
                        child: Row(
                          mainAxisAlignment: MainAxisAlignment.spaceBetween,
                          children: [
                            Text("结束时间",style: appThemeData.textTheme.bodyText1,),
                            // SizedBox(height: 12,),
                            Container(
                                height: 40,
                                child: Row(
                                  mainAxisAlignment:
                                  MainAxisAlignment.spaceAround,
                                  crossAxisAlignment: CrossAxisAlignment.center,
                                  children: [
                                    Text('${controller.endTime}',style: appThemeData.textTheme.subtitle1,),
                                    Icon(
                                      Icons.arrow_forward_ios,
                                      size: 15,
                                      color: AppColor.smallTextColor,
                                    )
                                  ],
                                )),
                          ],
                        ),
                      )),
                  SizedBox(height: 1,),
                  GestureDetector(
                      onTap: () async {
                        controller.tapClickStaff();
                      },
                      child: Container(
                        padding: EdgeInsets.fromLTRB(10, 10, 5, 10),
                        color: Colors.white,
                        child: Row(
                          mainAxisAlignment: MainAxisAlignment.spaceBetween,
                          children: [
                            Text("员工",style: appThemeData.textTheme.bodyText1,),
                            // SizedBox(height: 12,),
                            Container(
                                height: 40,
                                child: Row(
                                  mainAxisAlignment:
                                  MainAxisAlignment.spaceAround,
                                  crossAxisAlignment: CrossAxisAlignment.center,
                                  children: [
                                    Text('${controller.selectEmployee}',style: appThemeData.textTheme.subtitle1,),
                                    Icon(
                                      Icons.arrow_forward_ios,
                                      size: 15,
                                      color: AppColor.smallTextColor,
                                    )
                                  ],
                                )),
                          ],
                        ),
                      )),
                  SizedBox(height: 1,),
                  GestureDetector(
                      onTap: () async {
                        controller.tapClickDepartment();
                      },
                      child: Container(
                        padding: EdgeInsets.fromLTRB(10, 10, 5, 10),
                        color: Colors.white,
                        child: Row(
                          mainAxisAlignment: MainAxisAlignment.spaceBetween,
                          children: [
                            Text("部门",style: appThemeData.textTheme.bodyText1,),
                            // SizedBox(height: 12,),
                            Container(
                                height: 40,
                                child: Row(
                                  mainAxisAlignment:
                                  MainAxisAlignment.spaceAround,
                                  crossAxisAlignment: CrossAxisAlignment.center,
                                  children: [
                                    Text('${controller.selectDepartment}',style: appThemeData.textTheme.subtitle1,),
                                    Icon(
                                      Icons.arrow_forward_ios,
                                      size: 15,
                                      color: AppColor.smallTextColor,
                                    )
                                  ],
                                )),
                          ],
                        ),
                      )),
                  SizedBox(height: 1,),
                  GestureDetector(
                      onTap: () async {
                        controller.tapClickPost();
                      },
                      child: Container(
                        padding: EdgeInsets.fromLTRB(10, 10, 5, 10),
                        color: Colors.white,
                        child: Row(
                          mainAxisAlignment: MainAxisAlignment.spaceBetween,
                          children: [
                            Text("岗位",style: appThemeData.textTheme.bodyText1,),
                            // SizedBox(height: 12,),
                            Container(
                                height: 40,
                                child: Row(
                                  mainAxisAlignment:
                                  MainAxisAlignment.spaceAround,
                                  crossAxisAlignment: CrossAxisAlignment.center,
                                  children: [
                                    Text('${controller.selectPost}',style: appThemeData.textTheme.subtitle1,),
                                    Icon(
                                      Icons.arrow_forward_ios,
                                      size: 15,
                                      color: AppColor.smallTextColor,
                                    )
                                  ],
                                )),
                          ],
                        ),
                      )),
                  SizedBox(height: 1,),
                  GestureDetector(
                      onTap: () async {

                      },
                      child: Container(
                        padding: EdgeInsets.fromLTRB(10, 10, 5, 10),
                        color: Colors.white,
                        child: Row(
                          mainAxisAlignment: MainAxisAlignment.spaceBetween,
                          children: [
                            Text("薪水",style: appThemeData.textTheme.bodyText1,),
                            // SizedBox(height: 12,),
                            Container(
                                height: 40,
                                child: Row(
                                  mainAxisAlignment:
                                  MainAxisAlignment.spaceAround,
                                  crossAxisAlignment: CrossAxisAlignment.center,
                                  children: [
                                    Container(
                                      width: 60,
                                      height: 30,
                                      color: Colors.white,
                                      alignment: Alignment.centerRight,
                                      child: TextField(
                                        //设置键盘样式，
                                        keyboardType: TextInputType.multiline,
                                        controller: controller.wageTF,
                                        textDirection: TextDirection.rtl,
                                         inputFormatters: [
                                          FilteringTextInputFormatter(RegExp("[0-9.]"), allow: true),
                                          CustomTextFieldFormatter(digit: 2),
                                         ],

                                        decoration: InputDecoration(
                                          border: InputBorder.none,
                                          isCollapsed: true,
                                          hintText: '请输入薪水',
                                          hintStyle: TextStyle(

                                          )
                                        ),
                                      ),
                                    ),
                                    Text('￥')
                                  ],
                                )),
                          ],
                        ),
                      )),
                  SizedBox(height: 1,),
                  BrnInputText(
                    textEditingController: controller.notesTF,
                    padding: EdgeInsets.only(left: 10,right: 10,top: 5),
                    hint: '请输入备注',
                    maxLength: 25,
                  ),

                ],
              )),
              Container(
                color: Colors.white,
                child:  BottomEnterPage(() {
                  controller.tapClickDone();
                }),
              )
            ],
          ),
        );
      }),
    );
  }

}